package com.sunny.springboot2.event;

import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;

/**
 * 事件发布
 */
public class CustomEventPublisher implements ApplicationEventPublisherAware {

   private ApplicationEventPublisher publisher;

   public void setApplicationEventPublisher(ApplicationEventPublisher publisher){
      this.publisher = publisher;
   }

   public void publish() {
      CustomEvent ce = new CustomEvent(this);
      publisher.publishEvent(ce);
   }
}